﻿@model IEnumerable<mesoBoard.Data.User>

<div class="users section">
    <h2>Users</h2>
    
    <div class="pagination">
        @Html.Partial("_Pagination", ViewData["Pagination"])
    </div>    

    <table>    
        <tr>
            <th>@Html.ActionLink("Username", "Users", new { sort = "Username" })</th>
            <th>@Html.ActionLink("Email", "Users", new { sort = "Email" })</th>
            <th>@Html.ActionLink("Status", "Users", new { sort = "Status" })</th>
            <th>Last Login</th>
        </tr>
            
        @foreach(var user in Model)
        { 
            <tr class="@(string.IsNullOrEmpty(user.ActivationCode) ? "active" : "inactive")">
                <td>@Html.ActionLink(user.Username, "UserDetails", new { UserID = user.UserID })</td>
                <td>@user.Email</td>
                <td>
                    @if (string.IsNullOrWhiteSpace(user.ActivationCode))
                    {
                        <span class="active">Active</span>
                    }
                    else
                    {
                        <span class="inactive">Inactive</span>
                    }
                </td>
                <td>@Html.RelativeDate(user.LastLoginDate) from @user.LastLoginIP</td>
            </tr>
        }
    </table>

    <div class="pagination">
        @Html.Partial("_Pagination", ViewData["Pagination"])
    </div>        
</div>